<style>
    .a_click a{
        display: inline-block;
        text-align: center;
        padding: 2px 8px;
        background-color: #5bc0de;
        color: #fff;
        border-radius: 5px;
        margin-top: 10px;
    }
    .a_click a:hover{background-color: #46b8da;}
    
    .page{border-top: 1px solid #E0E0E0;padding: 5px 0 5px 0;}
    .page .page_count .paginate_button{
        margin: -4px;
        background-color: #D5D5D5;
        padding: 5px 12px;
        color: #7d7d7d;
        border-radius: 3px;
    }
    .page .page_count .paginate_button:hover{
        background-color: #89affc;
        color: #fff;
    }
    .page .page_count .paginate_active{
        margin: -4px;
        padding: 5px 12px;
        color: #fff;
        background-color: #89affc;
        border-radius: 3px;
    }
</style>

<section class="vbox">
    <section class="scrollable padder">
        <ul class="breadcrumb no-border no-radius b-b b-light pull-in">
            <li><a href="#"><i class="fa fa-home"></i>酒店管理中心</a></li>
            <li><a href="#">酒店管理</a></li>
            <li><a href="#">图片管理</a></li>
        </ul>
        <div class="m-b-md">
            <h3 class="m-b-none"><span style="float:right;"></span>图片管理</h3>
        </div>
        <section class="panel panel-default">
            <header class="panel-heading">
                <i data-title="ajax to load the data." data-placement="bottom" data-toggle="tooltip" class="fa fa-info-sign text-muted" data-original-title="" title=""></i> 
                <label style="color: #46b8da;font-weight: normal;">(<?=$toptitle?>)</label>
                <b>图片管理</b>
                <a href="<?=$this->url("hotel/type")?>" title="返回" style="float: right;"><i class="fa fa-reply icon"> 返回</i></a>
                <a href="<?=$this->url('hotel/pictureEdit?typeid='.$typeid.'&id=0')?>" title="添加图片" style="float: right;margin-right: 20px;"><i class="fa fa-plus-square icon"> 添加</i></a>
            </header>
            <table data-ride="datatables" class="table table-striped m-b-none dataTable" id="DataTables_Table_0" >
            <thead>
                <tr role="row">
                    <th>序号</th>
                    <th>名称</th>
                    <th>图片</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
            <?
            if(!empty($re)){
                foreach($re as $k=>$v){?>
                <tr role="row">
                    <td style="line-height: 50px;"><?=$k+1?></td>
                    <td style="line-height: 50px;"><?=$v['title']?></td>
                    <td><a href="<?=$v['pcurl']?>" target="_blank" title="查看大图"><img src="<?=$v['pcurl']?>" style="width: 100px;height: 50px;" /></a></td>
                    <td style="line-height: 50px;">
                        <?
                        if($v['status']==0){
                            echo '<font color="gray">审核中</font>';
                        }elseif($v['status']==1){
                            echo '<font color="green">正常</font>';
                        }elseif($v['status']==2){
                            echo '<font color="gray">未通过</font>';
                        }elseif($v['status']==3){
                            echo '<font color="red">已禁用</font>';
                        }
                        ?>
                    </td>
                    <td class="a_click">
                        <a href="<?=$this->url('hotel/pictureEdit?id='.$v["id"].'&typeid='.$typeid)?>" >修改</a>
                        <?if($v['status']==3){?>
                            <a href="javascript:void(0);" onclick="picstatus('<?=$v["id"]?>')" >使用</a>
                        <?}elseif($v['status']==1){?>
                            <a href="javascript:void(0);" onclick="picstatus('<?=$v["id"]?>')" >禁用</a>
                        <?}?>
                        <a href="javascript:void(0);" onclick="del('<?=$v["id"]?>')" >删除</a>
                    </td>
                </tr>
                <?}
            }else{?>
                <tr><td colspan="4">没有相关内容</td></tr>
            <?}
            ?>
            </tbody>
            </table>
            <div class="page">
                <?=$pageHtml?>
            </div>
        </section>
    </section>
</section>
<a href="#" class="hide nav-off-screen-block" data-toggle="class:nav-off-screen" data-target="#nav"></a>
<script type="text/javascript">
function picstatus(id){
    $.ajax({
		type:'POST',
		url:'<?=$this->url("hotel/pictureStatus")?>',
		data:'id='+id,
		dataType:'json',
		success:function(r){
		    if(r.state==1){
		        pub_alert_success(r.html,2000);
                setTimeout(function(){window.location.reload()},2000);
		    }else if(r.state==0){
		        pub_alert_error(r.html,2000);
		    }
		},
        error:function(){
            pub_alert_error("ajax出现错误");
        }
	});
}
function del(id){
    if(confirm("删除后不可恢复！确认删除？")){
        $.ajax({
    		type:'POST',
    		url:'<?=$this->url("hotel/pictureDel")?>',
    		data:'id='+id,
    		dataType:'json',
    		success:function(r){
    		    if(r.state==1){
    		        pub_alert_success(r.html,2000);
                    setTimeout(function(){window.location.reload()},2000);
    		    }else if(r.state==0){
    		        pub_alert_error(r.html,2000);
    		    }
    		},
            error:function(){
                pub_alert_error("ajax出现错误");
            }
    	});
    }
}
</script>